{% extends "common-content.html" %}

{% block info_float %}
    {% if request.user.is_authenticated %}
        {% with profile=request.user.profile %}
            {% if profile in organization %}
                <form method="post" action="{{ url('leave_organization', organization.id, organization.slug) }}">
                    {% csrf_token %}
                    <input type="submit" class="unselectable button full" value="{{ _('Leave organization') }}">
                </form>
            {% elif organization.is_open %}
                <form method="post" action="{{ url('join_organization', organization.id, organization.slug) }}">
                    {% csrf_token %}
                    <input type="submit" class="unselectable button full" value="{{ _('Join organization') }}">
                </form>
            {% else %}
                <a href="{{ url('request_organization', organization.id, organization.slug) }}"
                   class="unselectable button full">{{ _('Request membership') }}</a>
            {% endif %}
        {% endwith %}
        <hr>
    {% endif %}

    {% if can_edit %}
        <div><a href="{{ url('edit_organization', organization.id, organization.slug) }}">{{ _('Edit organization') }}</a></div>

        {% if not organization.is_open %}
            <div>
                <a href="{{ url('organization_requests_pending', organization.id, organization.slug) }}">{{ _('View requests') }}</a>
            </div>
        {% endif %}
    {% endif %}

    {% if perms.judge.change_organization %}
        <div>
            <a href="{{ url('admin:judge_organization_change', organization.id) }}">{{ _('Admin organization') }}</a>
        </div>
    {% endif %}

    <div>
        <a href="{{ organization.get_users_url() }}">{{ _('View members') }}</a>
    </div>
{% endblock %}

{% block description %}
    {% cache 3600 'organization_html' organization.id MATH_ENGINE %}
        {{ organization.about|markdown('organization-about', MATH_ENGINE)|reference|str|safe }}
    {% endcache %}
{% endblock %}
